<script>
  init({
    title: 'Scroll To',
    desc: 'Scroll to the number value position, set \'bottom\' means scroll to the bottom:<br>`$table.bootstrapTable(\'scrollTo\', 0)`<br>`$table.bootstrapTable(\'scrollTo\', {unit: \'rows\', value: index})`<br>`$table.bootstrapTable(\'scrollTo\', \'bottom\')`.',
    links: ['bootstrap-table.min.css'],
    scripts: ['bootstrap-table.min.js']
  })
</script>

<style>
.row-index {
  display: inline-block;
  width: 100px;
  vertical-align: middle;
}
</style>

<div id="toolbar">
  <button id="button" class="btn btn-secondary">scrollTo Top</button>
  <button id="button2" class="btn btn-secondary">Scroll to row index: </button>
  <input type="number"
    class="form-control row-index"
    value="3" min="0">
  <button id="button3" class="btn btn-secondary">scrollTo Bottom</button>
</div>
<table
  id="table"
  data-toggle="table"
  data-toolbar="#toolbar"
  data-height="460"
  data-url="json/data1.json">
  <thead>
    <tr>
      <th data-field="id">ID</th>
      <th data-field="name">Item Name</th>
      <th data-field="price">Item Price</th>
    </tr>
  </thead>
</table>

<script>
  var $table = $('#table')
  var $button = $('#button')
  var $button2 = $('#button2')
  var $button3 = $('#button3')

  function mounted() {
    $button.click(function () {
      $table.bootstrapTable('scrollTo', 0)
    })
    $button2.click(function () {
      var index = +$('.row-index').val()
      $table.bootstrapTable('scrollTo', {unit: 'rows', value: index})
    })
    $button3.click(function () {
      $table.bootstrapTable('scrollTo', 'bottom')
    })
  }
</script>
